package org.apcs.pokemon.mechanics;

/**
 * Author:          Zachary Reed
 * Date Created:    Mar 25, 2010
 * Last Modified:   Apr 14, 2010
 * Package:         org.apcs.pokemon.mechanics
 * Filename:        Trainer.java
 * Description:     A class that defines a Trainer object, which holds data
 *                  about the local player.
 */

import java.util.ArrayList;
import java.util.Random;
import org.apcs.pokemon.pokemon.Pokemon;

public class Trainer {

	private String strName = "";
	private boolean blnGender = true;
	private int intTrainerID = 0;
	private int intMoney = 1000;
    private int intPokemon = 0;
	private ArrayList<Pokemon> arrPokemon = new ArrayList<Pokemon>();

	private static Random rand = new Random();

    /**
     * Creates a Trainer object, which holds all data about the local player
     * necessary to play the game.
     *
     * Not for players over a network connection (see io.net.Player).
     * @param name Name of the player
     * @param gender Gender of the player (true: male, false: female)
     */
	public Trainer(String name,boolean gender) {
		strName = name;
		blnGender = gender;
		intTrainerID = calcID();
	}

    /** Add a pokemon to the trainer's party. */
    public void addPokemon(Pokemon p) {
        if (intPokemon<6) {
            arrPokemon.add(p);
            intPokemon++;
        }
    }

    /** Remove a pokemon from the trainer's party. */
    public void remPokemon(int index) {
        if (intPokemon>0) {
            arrPokemon.remove(index);
            intPokemon--;
        }
    }

    public Pokemon party(int index) {return arrPokemon.get(index);}

    /**
     * Returns the name of the trainer.
     * @return The player's name.
     */
	public String name() {return strName;}

    /**
     * Returns the trainer ID of the player as an integer.
     * @return The player's trainer ID.
     */
	public int ID() {return intTrainerID;}

    /**
     * Calculates a new trainer ID (only used when creating a new trainer.)
     * @return A new trainer ID
     */
	private static int calcID() {return (rand.nextInt(99999) + 1);}
}
